<!--
 * @Description: 工单打印组件
 * @Autor: 何兴家
 * @Date: 2021-02-01 16:49:46
 * @LastEditors: 马毅
 * @LastEditTime: 2021-10-19 13:16:26
-->
<template>
  <div>
    <AjaxButton type="primary" :disabled="disabled" :click="handlePrint">打印工单</AjaxButton>

    <!-- 打印组件 -->
    <BasePrint ref="print" :showTopIcon="true" :title="printTitle" :data="printData" :isPreview="false" template="repair/repairOrder" />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { confirmAction, notifyAction, findFormItem, findTableItem } from '@/utils';
import { getAppId } from '@/assets/js/auth';

import { printRepairOrder } from '@/api/repair/repairReception/customer';

export default {
  props: ['disabled', 'roNo'],
  mixins: [dictionary],
  data() {
    return {
      printData: {} // 打印数据
    };
  },
  computed: {
    printTitle() {
      return (getAppId() == 'beijing' ? '北京汽车' : '蓝谷极狐') + '售后维修业务委托书';
    }
  },
  methods: {
    // 点击打印工单
    async handlePrint() {
      let res = await printRepairOrder({ roNo: this.roNo });
      if (res.resultCode == 200) {
        this.printData = res.data;
        this.$refs.print.EXCUTE_PRINT();
        this.$emit('printSuccess');
      }
    }
  }
};
</script>

<style scoped></style>
